package com.yuexun.dhdoctor.module.meetingNew.presenter.impl;

import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.meetingNew.bean.MeetingNewSignBean;
import com.yuexun.dhdoctor.module.meetingNew.model.IMeetingNewModel;
import com.yuexun.dhdoctor.module.meetingNew.presenter.IMeetingNewSignPresenter;
import com.yuexun.dhdoctor.module.meetingNew.ui.view.IMeetingNewSignView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2017/4/10 0010.
 */

public class MeetingNewSignPresenter implements IMeetingNewSignPresenter {

    private IMeetingNewSignView view;
    private IMeetingNewModel model;

    public MeetingNewSignPresenter(IMeetingNewModel model, IMeetingNewSignView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void getMeetingSign(Map<String, String> praise) {
        model.getMeetingSign(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<MeetingNewSignBean>>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("会议信息请求失败,请检查网络连接");
                    }

                    @Override
                    public void onNext(BaseEntity<MeetingNewSignBean> meetingBean) {
                        view.showMeetingSignList(meetingBean);
                    }
                });
    }
}
